home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-10-15 | 4.6 KB | 187 lines | [TEXT/MPS ] |
- (*
- File: ThreadedVUTool.vu
-
- Contains:
- Virtual User 2.1a2 script for testing threaded external tool services.
- The basic threaded services are EchoThread and EchoNoThread.
-
-
- Written by: Stuart Russell
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- 01/10/95 SBR modified for ETO.
- 11/18/94 SBR created.
-
- To Do:
- *)
-
-
- Libraries "ThreadedVUTool.vulib";
-
- task ReturnErrorString( errorStringEntry )
- begin
- if IsUndefined( errorStringEntry )
- return "";
- else
- return errorStringEntry;
- end;
-
- script TryThreading
- (
- PauseThread1 := 600,
- PauseThread2 := 600,
- PauseThread3 := 600,
- PauseThread4 := 600,
- PauseNonThreaded := 180,
- randomPause := false,
- doBeep := true,
- beepEveryN := 0,
- sleep_ticks := 1,
- useLists := true,
- run_continuously := false,
- LaunchOnTarget := false
- )
- begin
- ExternalToolTimeout(9999);
-
- if doBeep
- doBeep := true;
- else
- doBeep := false;
-
- oldActorName := ActorName( 'waiting' );
-
- ActorName( oldActorName );
-
- m := ThreadedVUTool( "Initialize", LaunchOnTarget); # Initialize the ThreadedVUTool.
- println 'ThreadedVUTool( "Initialize"): ',m;
- if m[1] <> 0 # If error during initialization,
- begin
- println "ThreadedVUTool could not be initialized"; # print error
- println "Error ", m[1], ". ", ReturnErrorString( m[3] );
- exit; # & exit this script.
- end;
-
- if sleep_ticks >= 0
- begin
- m := ThreadedVUTool( "SetSleepTicks", sleep_ticks); # set the sleep ticks for WaitNextEvent.
- println "ThreadedVUTool( 'SetSleepTicks', {sleep_ticks}): ",m;
- end;
-
- rList :=
- {
- { {{{{1,{},{'gump'},{}},{{true,{{'325434t',23232,'ΩΩΩΩΩΩΩ'}}}},false},{}},{}} },
- { 4 },
- { true },
- { false },
- { 4 },
- { true },
- { false },
- { 4 },
- { true },
- { false },
- {}
- };
-
- rListSize := card rList;
-
- if run_continuously
- run_continuously := 99999999;
- else
- run_continuously := 0;
-
- for run_continuously := run_continuously to 0 step -1
- begin
- if randomPause
- begin
- PauseNonThreaded := random( 0, PauseNonThreaded );
- PauseThread1 := random( 0, PauseThread1 );
- PauseThread2 := random( 0, PauseThread2 );
- PauseThread3 := random( 0, PauseThread3 );
- PauseThread4 := random( 0, PauseThread4 );
- end;
-
- if useLists
- begin
- itemS := rList[random(1,rListSize)];
- item1 := rList[random(1,rListSize)];
- item2 := rList[random(1,rListSize)];
- item3 := rList[random(1,rListSize)];
- item4 := rList[random(1,rListSize)];
- end;
- else
- begin
- itemS := {}; item1 := {}; item2 := {}; item3 := {}; item4 := {};
- end;
-
- if PauseNonThreaded
- begin
- theSync1 := ThreadedVUTool('EchoNoThread',itemS,PauseNonThreaded,doBeep, beepEveryN) async: false;
- end;
-
- if PauseThread1
- begin
- theAsync1 := ThreadedVUTool('EchoThread',item1,PauseThread1,doBeep, beepEveryN) async: true;
- end;
-
- if PauseThread2
- begin
- theAsync2 := ThreadedVUTool('EchoThread',item2,PauseThread2,doBeep, beepEveryN) async: true;
- end;
-
- if PauseThread3
- begin
- theAsync3 := ThreadedVUTool('EchoThread',item3,PauseThread3,doBeep, beepEveryN) async: true;
- end;
-
- if PauseThread4
- begin
- theAsync4 := ThreadedVUTool('EchoThread',item4,PauseThread4,doBeep, beepEveryN) async: true;
- end;
-
- ActorName( oldActorName );
-
- while (theSync1[1] = 1) or (theAsync1[1] = 1) or (theAsync2[1] = 1) or (theAsync3[1] = 1) or (theAsync4[1] = 1)
- begin
- #println "1: ", theAsync1, " 2: ", theAsync2, " 3: ", theSync1;
-
- if PauseThread1 and (theAsync1[1] = 1)
- theAsync1 := ThreadedVUTool('poll',theAsync1[2]) ;
-
- if PauseThread2 and (theAsync2[1] = 1)
- theAsync2 := ThreadedVUTool('poll',theAsync2[2]) ;
-
- if PauseThread3 and (theAsync3[1] = 1)
- theAsync3 := ThreadedVUTool('poll',theAsync3[2]) ;
-
- if PauseThread4 and (theAsync4[1] = 1)
- theAsync4 := ThreadedVUTool('poll',theAsync4[2]) ;
-
- if PauseNonThreaded and (theSync1[1] = 1)
- theSync1 := ThreadedVUTool('poll',theSync1[2]) ;
- end;
- if theAsync1
- if theAsync1[1] <> 0 or theAsync1[2] <> item1
- println "ERROR theAsync1 = {theAsync1}, item1 = {item1}";
- if theAsync2
- if theAsync2[1] <> 0 or theAsync2[2] <> item2
- println "ERROR theAsync2 = {theAsync2}, item2 = {item2}";
- if theAsync3
- if theAsync3[1] <> 0 or theAsync3[2] <> item3
- println "ERROR theAsync3 = {theAsync3}, item3 = {item3}";
- if theAsync4
- if theAsync4[1] <> 0 or theAsync4[2] <> item4
- println "ERROR theAsync4 = {theAsync4}, item4 = {item4}";
- if theSync1
- if theAsync1[1] <> 0 or theSync1[2] <> itemS
- println "ERROR theSync1 = {theSync1}, itemS = {itemS}";
- println "1:", theAsync1, " 2:", theAsync2, " 3:", theAsync3, " 4:", theAsync4, " 5:", theSync1;
- end;
-
- ThreadedVUTool('quit') ;
- end;
-
-